var path = require("path");
var htmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
    entry: "./src/js/index.js",
    output: {
        path: path.resolve(__dirname, "./dist"),
        filename: "index.bundle.js"
    },
    module: {
        loaders: [{
            test: /\.css$/,
            loader: "style-loader!css-loader"
             },
            {
                test: /\.less$/,
                loader: "style-loader!css-loader!less-loader"
            },
            {
                test:/\.js$/,
                loader: "babel-loader",
                query: {
                    presets:["latest"]
                }
            },
            {
                test:/\.html$/,
                loader: "html-withimg-loader"
            },
            {// 图片加载器url-loader，雷同file-loader，更适合图片，可以将较小的图片转成base64，减少http请求
                // 如下配置，将小于8192byte的图片转成base64码
                test:/\.(jpg|jpeg|gif|png)$/,
                loaders:[ "url-loader?name=img/[name]-[hash:5].[ext]",
                            "image-webpack-loader"
                ]
            }
        ]
    },
    plugins: [
        new htmlWebpackPlugin({
        template:"index.html",
        path:path.resolve(__dirname,"./dist"),
        filename:"index.html",
        inject:"body"
    })]
};